package org.jwcloud.project.module.zx.timingSz.controller;

import java.util.Map;

import com.jw.mid.mm.comm.common.json.Response;
import com.jw.mid.mm.comm.common.pagination.PageListSlice;

import org.jwcloud.project.module.zx.common.FmtUtil;
import org.jwcloud.project.module.zx.common.Resp;
import org.jwcloud.project.module.zx.timingSz.service.RptTimingSzService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import com.jw.mid.mm.comm.common.controller.BaseController;
import com.jw.mid.mm.comm.common.pagination.Pagination;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

@Api(value = "API - Controlle",
        description = "shixiaoguanli", tags = "timingSz")
@RestController
@RequestMapping("/rest/rptTimingSz")
public class RptTimingSzController extends BaseController {

    @Autowired
    public RptTimingSzService rptTimingSzService;

    @GetMapping("queryTaskList_sz")
    @ApiOperation(value = "任务列表 设置", notes = "主列表  分页")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "id", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "task_code", value = "task_code", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "task_name", value = "task_name", required = false, dataType = "string", paramType = "query"),
    })
    public Resp queryTaskList_sz(
            Pagination pagination,
            @RequestParam(required = false) Map<String, String> param
    ) {
        return rptTimingSzService.queryTemplateList(pagination, param);
    }

    @GetMapping("queryTaskInfoList")
    @ApiOperation(value = "任务信息列表", notes = "任务信息列表")
    @ApiImplicitParams({
            //@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "work_id", value = "work_id", required = true, dataType = "string", paramType = "query"),

            @ApiImplicitParam(name = "pagi", value = "分页参数 currentPage pagisize...", required = false, dataType = "string", paramType = "query"),
    })
    public Resp<Response<PageListSlice>> queryTaskInfoList(
            Pagination pagination,
            @RequestParam(required = false) Map<String, String> param
    ) {
        return rptTimingSzService.queryTaskInfoListById(pagination,param);
    }


    @PostMapping("updateTime")
    @ApiOperation(value = "时效设置", notes = "时效设置")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "id", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "tip_day", value = "提醒时间", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "warn_first_day", value = "一次预警时间", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "warn_second_day", value = "二次预警时间", required = true, dataType = "string", paramType = "query"),
    })
    public Resp<Object> updateTime(
            @RequestBody(required = false) Map<String, String> param
    ) {
    	
    	String flag = FmtUtil.nullRes(param
				, "tip_day", "提醒时间"
				, "warn_first_day", "一次预警时间"
				, "warn_second_day", "二次预警时间"
				, "id", "id");
		if(!StringUtils.isEmpty(flag)) 
			return Resp.error(flag);
    	
        return rptTimingSzService.updateTiming(param);
    }


}